/**
 * @author liyongjie
 * @time 2018年6月8日 上午9:46:36
 * @version v1.0
 * @description 测试大量发送http请求
 */
package desp.test.inner.demo;

import java.io.IOException;

import javax.swing.text.html.parser.Entity;

import org.apache.commons.io.IOUtils;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class HttpsClientPoolUtil {
	private static Logger logger = LoggerFactory.getLogger(HttpsClientPoolUtil.class);
	private static PoolingHttpClientConnectionManager cm =null;
	private static CloseableHttpClient httpClint =null;
	private static final String POST_URL="";
	
	/**
	 * 默认cotent 类型
	 */
	
	private static final String DEFAULT_CONTENT_TYPE ="appliaction/json";
	
	public static void main(String[] args) throws Exception {
		String postmsg = getRequestMsg();
		CloseableHttpClient httpclient =   HttpClients.custom().build();
		try{
		HttpPost httpPost = new HttpPost(POST_URL);
		
		StringEntity se = new StringEntity(postmsg,"UTF-8");
		
		se.setContentType(DEFAULT_CONTENT_TYPE);
		
		se.setContentEncoding("UTF-8");
		
		httpPost.setEntity(se);
		
		CloseableHttpResponse response = httpclient.execute(httpPost);
		try{
			HttpEntity entity = response.getEntity();
			if(200==(response.getStatusLine().getStatusCode())){
				String respstr = IOUtils.toString(entity.getContent());
				//进行报文验签
				
			}
		}finally{
			response.close();
		}
		}finally{
			httpclient.close();
		}
	}
	public static String getRequestMsg(){
		return null;
	}

}
